import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import '../../../../l10n/local.dart';

// 最大值view
class IQOutputMaxView extends StatelessWidget {
  final RxDouble maxOutputRate;
  final String unit;

  final Function()? onClear;

  const IQOutputMaxView(this.maxOutputRate,
      {this.onClear, this.unit = '', super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          height: 70.w,
          decoration: BoxDecoration(
            color: Colors.transparent,
            border: Border.all(color: Colors.greenAccent.withOpacity(0.4)),
            borderRadius: BorderRadius.circular(8),
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Padding(
                padding: const EdgeInsets.only(left: 16.0),
                child: RichText(
                  text: TextSpan(
                    children: [
                      const TextSpan(
                        text: 'Max: ',
                        style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                          color: Colors.greenAccent, // 科技蓝
                          shadows: [
                            Shadow(
                              color: Colors.greenAccent,
                              blurRadius: 4,
                              offset: Offset(0, 1),
                            ),
                          ],
                        ),
                      ),
                      TextSpan(
                        text: '${maxOutputRate.value.toStringAsFixed(1)} ',
                        style: const TextStyle(
                          fontSize: 20,
                          fontWeight: FontWeight.bold,
                          color: Colors.greenAccent, // 科技蓝
                          shadows: [
                            Shadow(
                              color: Colors.greenAccent,
                              blurRadius: 4,
                              offset: Offset(0, 1),
                            ),
                          ],
                        ),
                      ),
                      TextSpan(
                        text: unit,
                        style: const TextStyle(
                          fontSize: 12,
                          color: Colors.greenAccent, // 科技蓝
                          shadows: [
                            Shadow(
                              color: Colors.greenAccent,
                              blurRadius: 4,
                              offset: Offset(0, 1),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(right: 16.0),
                child: LxButton(
                  onTap: onClear,
                  title: local.clear,
                  buttonTypeCustomColor: ButtonTypeColor()
                    ..backgroundColor = GrayColor.gray3.withOpacity(0.4)
                    ..borderColor = Colors.transparent
                    ..textColor = Colors.white.withOpacity(0.8),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
